﻿using System;
using System.Collections;
using System.Linq;
using Ones.Infrastructure.Utils.Pagination;

namespace Ones.Utils.UserControls
{
    public partial class Pager : System.Web.UI.UserControl, IPagination
    {
        #region Member Variables
        
        protected int _pageSize;
        protected int _pageNumber;
        protected int _totalItems;
        protected int _firstItem;
        protected int _lastItem;
        protected bool _hasNextPage;
        protected bool _hasPreviousPage;
        /////
        protected string _url = "";
        
        #endregion
        
        public IEnumerator GetEnumerator()
        {
            // TODO: Implement this method
            throw new NotImplementedException();
        }
        
        #region Getter/Setter
        
        public int PageSize
        {
            get
            {
                return _pageSize;
            }
            set
            {
                _pageSize = value;
            }
        }
        
        public int PageNumber
        {
            get
            {
                return _pageNumber;
            }
            set
            {
                _pageNumber = value;
            }
        }
        
        public int TotalItems
        {
            get
            {
                return _totalItems;
            }
            set
            {
                _totalItems = value;
            }
        }
        
        public int TotalPages
        {
            get
            {
                return (int)Math.Ceiling(((double)TotalItems) / PageSize);
            }
        }
        
        public int FirstItem
        {
            get
            {
                return _firstItem;
            }
            set
            {
                _firstItem = value;
            }
        }
        
        public int LastItem
        {
            get
            {
                return _lastItem;
            }
            set
            {
                _lastItem = value;
            }
        }
        
        public bool HasPreviousPage
        {
            get
            {
                return _hasPreviousPage;
            }
            set
            {
                _hasPreviousPage = value;
            }
        }
        
        public bool HasNextPage
        {
            get
            {
                return _hasNextPage;
            }
            set
            {
                _hasNextPage = value;
            }
        }
        
        public string Url
        {
            get
            {
                return this._url;
            }
            set
            {
                this._url = value;
            }
        }
        
        #endregion
        
        protected void Page_Load(object sender, EventArgs e)
        {
        }
    }
}